package com.hubery.designpattern.design.decorator;

import com.hubery.designpattern.design.decorator.dto.UserInfoDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lixueyang
 * @since 2023/2/28 9:01
 */
@Slf4j
@Component
public abstract class AbstractFillUserInfoDecorator {

    private static final Map<String, UserInfoDTO> USER_MAP = new HashMap<>();

    static {
        USER_MAP.put("1", UserInfoDTO.builder().userId("1").username("大山").build());
        USER_MAP.put("2", UserInfoDTO.builder().userId("2").username("二狗子").build());
    }

    public UserInfoDTO fillUserInfo(String userId) {
        UserInfoDTO userInfoDTO = USER_MAP.getOrDefault(userId, null);
        log.info("用户 【{}】 基础数据填充", userInfoDTO.getUsername());
        return userInfoDTO;
    }
}
